package ar.com.mindset.geometrics.colorSchemes.continuous {
	import ar.com.mindset.geometrics.ColorEntry;
	import ar.com.mindset.geometrics.colorSchemes.ContinuousColorScheme;

	import mx.collections.ArrayCollection;
	import mx.collections.Sort;
	import mx.collections.SortField;

	[DefaultProperty("manualValues")]

	public class ManualDivisionStrategy implements DivisionStrategy {
		private var _defaultColor:Object="#000000";
		private var _manualValues:ArrayCollection;

		public function getDivisions(colorScheme:ContinuousColorScheme, regionDataCollection:ArrayCollection, valuePropertyName:String):ArrayCollection {
			return _manualValues;
		}

		public function get defaultColor():Object {
			return _defaultColor;
		}

		public function set defaultColor(dc:Object):void {
			_defaultColor=dc;
		}

		public function set manualValues(values:ArrayCollection):void {
			var sort:Sort=new Sort();
			sort.fields=[new SortField("key")];
			values.sort=sort;
			values.refresh();
			var previousKey:Object=null;
			for each (var element:ColorEntry in values) {
				if (previousKey == element.key) {
					//Throw exception
					throw new Error("Repeated keys in manual values");
				}
				previousKey=element.key
			}
			this._manualValues=values;
		}

		public function get manualValues():ArrayCollection {
			return this._manualValues;
		}

	}
}